package com.hopu.blb_erp.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hopu.blb_erp.entity.PageEntity;
import com.hopu.blb_erp.entity.TIomWarehouse;
import com.hopu.blb_erp.entity.TMenu;
import com.hopu.blb_erp.mapper.TIomWarehouseMapper;
import com.hopu.blb_erp.service.TIomWarehouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TIomWarehouseServiceImpl extends ServiceImpl<TIomWarehouseMapper, TIomWarehouse> implements TIomWarehouseService {
    @Autowired
    private TIomWarehouseMapper tIomWarehouseMapper;

    @Override
    public List<TIomWarehouse> findAll(String iomName) {
        return tIomWarehouseMapper.selectByName(iomName);
    }

    @Override
    public List<TIomWarehouse> findAlls() {
        return tIomWarehouseMapper.selectAll();
    }


    @Override
    public PageEntity<TIomWarehouse> findPage(Integer current, Integer length, String iomName, String iomGoods, String iomGoodsno) {
        Integer count = tIomWarehouseMapper.selectCounts(iomName, iomGoods, iomGoodsno);
        List<TIomWarehouse> tMenus = tIomWarehouseMapper.selectPages((current - 1) * length, length, iomName, iomGoods, iomGoodsno);
        tMenus.forEach(tMenu -> {
            System.out.println(tMenu.getTioWarehouses());
            System.out.println(tMenu.getTMenus());
            System.out.println(tMenu.getCommodities());
        });
        PageEntity<TIomWarehouse> tMenuPageEntity = new PageEntity<>();
        tMenuPageEntity.setData(tMenus);
        tMenuPageEntity.setCurrent(current);
        tMenuPageEntity.setCount(count);
        return tMenuPageEntity;
    }

    @Override
    public TIomWarehouse selectById(Integer id) {
        return tIomWarehouseMapper.selectById(id);
    }

    @Override
    public List<TIomWarehouse> selectsAll() {
        return tIomWarehouseMapper.selectsAll();
    }

    @Override
    public List<TIomWarehouse> selectsAllTwo() {
        return tIomWarehouseMapper.selectsAllTwo();
    }

    @Override
    public List<TIomWarehouse> selectsAllThree() {
        return tIomWarehouseMapper.selectsAllThree();
    }
}


